home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-12.z / lispref.info-12
Encoding:
GNU Info File  |  1998-05-21  |  50.9 KB  |  1,207 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Dynamic Loading,  Next: Eval During Compile,  Prev: Docs and Compilation,  Up: Byte Compilation
  48.  
  49. Dynamic Loading of Individual Functions
  50. =======================================
  51.  
  52.    When you compile a file, you can optionally enable the "dynamic
  53. function loading" feature (also known as "lazy loading").  With dynamic
  54. function loading, loading the file doesn't fully read the function
  55. definitions in the file.  Instead, each function definition contains a
  56. place-holder which refers to the file.  The first time each function is
  57. called, it reads the full definition from the file, to replace the
  58. place-holder.
  59.  
  60.    The advantage of dynamic function loading is that loading the file
  61. becomes much faster.  This is a good thing for a file which contains
  62. many separate commands, provided that using one of them does not imply
  63. you will soon (or ever) use the rest.  A specialized mode which provides
  64. many keyboard commands often has that usage pattern: a user may invoke
  65. the mode, but use only a few of the commands it provides.
  66.  
  67.    The dynamic loading feature has certain disadvantages:
  68.  
  69.    * If you delete or move the compiled file after loading it, Emacs
  70.      can no longer load the remaining function definitions not already
  71.      loaded.
  72.  
  73.    * If you alter the compiled file (such as by compiling a new
  74.      version), then trying to load any function not already loaded will
  75.      get nonsense results.
  76.  
  77.    If you compile a new version of the file, the best thing to do is
  78. immediately load the new compiled file.  That will prevent any future
  79. problems.
  80.  
  81.    The byte compiler uses the dynamic function loading feature if the
  82. variable `byte-compile-dynamic' is non-`nil' at compilation time.  Do
  83. not set this variable globally, since dynamic loading is desirable only
  84. for certain files.  Instead, enable the feature for specific source
  85. files with file-local variable bindings, like this:
  86.  
  87.      -*-byte-compile-dynamic: t;-*-
  88.  
  89.  - Variable: byte-compile-dynamic
  90.      If this is non-`nil', the byte compiler generates compiled files
  91.      that are set up for dynamic function loading.
  92.  
  93.  - Function: fetch-bytecode FUNCTION
  94.      This immediately finishes loading the definition of FUNCTION from
  95.      its byte-compiled file, if it is not fully loaded already.  The
  96.      argument FUNCTION may be a compiled-function object or a function
  97.      name.
  98.  
  99. 
  100. File: lispref.info,  Node: Eval During Compile,  Next: Compiled-Function Objects,  Prev: Dynamic Loading,  Up: Byte Compilation
  101.  
  102. Evaluation During Compilation
  103. =============================
  104.  
  105.    These features permit you to write code to be evaluated during
  106. compilation of a program.
  107.  
  108.  - Special Form: eval-and-compile BODY
  109.      This form marks BODY to be evaluated both when you compile the
  110.      containing code and when you run it (whether compiled or not).
  111.  
  112.      You can get a similar result by putting BODY in a separate file
  113.      and referring to that file with `require'.  Using `require' is
  114.      preferable if there is a substantial amount of code to be executed
  115.      in this way.
  116.  
  117.  - Special Form: eval-when-compile BODY
  118.      This form marks BODY to be evaluated at compile time and not when
  119.      the compiled program is loaded.  The result of evaluation by the
  120.      compiler becomes a constant which appears in the compiled program.
  121.      When the program is interpreted, not compiled at all, BODY is
  122.      evaluated normally.
  123.  
  124.      At top level, this is analogous to the Common Lisp idiom
  125.      `(eval-when (compile eval) ...)'.  Elsewhere, the Common Lisp `#.'
  126.      reader macro (but not when interpreting) is closer to what
  127.      `eval-when-compile' does.
  128.  
  129. 
  130. File: lispref.info,  Node: Compiled-Function Objects,  Next: Disassembly,  Prev: Eval During Compile,  Up: Byte Compilation
  131.  
  132. Compiled-Function Objects
  133. =========================
  134.  
  135.    Byte-compiled functions have a special data type: they are
  136. "compiled-function objects".
  137.  
  138.    A compiled-function object is a bit like a vector; however, the
  139. evaluator handles this data type specially when it appears as a function
  140. to be called.  The printed representation for a compiled-function
  141. object normally begins with `#<compiled-function' and ends with `>'.
  142. However, if the variable `print-readably' is non-`nil', the object is
  143. printed beginning with `#[' and ending with `]'.  This representation
  144. can be read directly by the Lisp reader, and is used in byte-compiled
  145. files (those ending in `.elc').
  146.  
  147.    In Emacs version 18, there was no compiled-function object data type;
  148. compiled functions used the function `byte-code' to run the byte code.
  149.  
  150.    A compiled-function object has a number of different elements.  They
  151. are:
  152.  
  153. ARGLIST
  154.      The list of argument symbols.
  155.  
  156. INSTRUCTIONS
  157.      The string containing the byte-code instructions.
  158.  
  159. CONSTANTS
  160.      The vector of Lisp objects referenced by the byte code.  These
  161.      include symbols used as function names and variable names.
  162.  
  163. STACKSIZE
  164.      The maximum stack size this function needs.
  165.  
  166. DOC-STRING
  167.      The documentation string (if any); otherwise, `nil'.  The value may
  168.      be a number or a list, in case the documentation string is stored
  169.      in a file.  Use the function `documentation' to get the real
  170.      documentation string (*note Accessing Documentation::.).
  171.  
  172. INTERACTIVE
  173.      The interactive spec (if any).  This can be a string or a Lisp
  174.      expression.  It is `nil' for a function that isn't interactive.
  175.  
  176. DOMAIN
  177.      The domain (if any).  This is only meaningful if I18N3
  178.      (message-translation) support was compiled into XEmacs.  This is a
  179.      string defining which domain to find the translation for the
  180.      documentation string and interactive prompt.  *Note Domain
  181.      Specification::.
  182.  
  183.    Here's an example of a compiled-function object, in printed
  184. representation.  It is the definition of the command `backward-sexp'.
  185.  
  186.      #<compiled-function
  187.        (&optional arg)
  188.        "¼é┴┬[!ç"
  189.        [arg 1 forward-sexp]
  190.        2
  191.        579173
  192.        "_p">
  193.  
  194.    The primitive way to create a compiled-function object is with
  195. `make-byte-code':
  196.  
  197.  - Function: make-byte-code &rest ELEMENTS
  198.      This function constructs and returns a compiled-function object
  199.      with ELEMENTS as its elements.
  200.  
  201.      *NOTE:* Unlike all other Emacs-lisp functions, calling this with
  202.      five arguments is *not* the same as calling it with six arguments,
  203.      the last of which is `nil'.  If the INTERACTIVE arg is specified
  204.      as `nil', then that means that this function was defined with
  205.      `(interactive)'.  If the arg is not specified, then that means the
  206.      function is not interactive.  This is terrible behavior which is
  207.      retained for compatibility with old `.elc' files which expected
  208.      these semantics.
  209.  
  210.    You should not try to come up with the elements for a
  211. compiled-function object yourself, because if they are inconsistent,
  212. XEmacs may crash when you call the function.  Always leave it to the
  213. byte compiler to create these objects; it makes the elements consistent
  214. (we hope).
  215.  
  216.    The following primitives are provided for accessing the elements of
  217. a compiled-function object.
  218.  
  219.  - Function: compiled-function-arglist FUNCTION
  220.      This function returns the argument list of compiled-function object
  221.      FUNCTION.
  222.  
  223.  - Function: compiled-function-instructions FUNCTION
  224.      This function returns a string describing the byte-code
  225.      instructions of compiled-function object FUNCTION.
  226.  
  227.  - Function: compiled-function-constants FUNCTION
  228.      This function returns the vector of Lisp objects referenced by
  229.      compiled-function object FUNCTION.
  230.  
  231.  - Function: compiled-function-stack-size FUNCTION
  232.      This function returns the maximum stack size needed by
  233.      compiled-function object FUNCTION.
  234.  
  235.  - Function: compiled-function-doc-string FUNCTION
  236.      This function returns the doc string of compiled-function object
  237.      FUNCTION, if available.
  238.  
  239.  - Function: compiled-function-interactive FUNCTION
  240.      This function returns the interactive spec of compiled-function
  241.      object FUNCTION, if any.  The return value is `nil' or a
  242.      two-element list, the first element of which is the symbol
  243.      `interactive' and the second element is the interactive spec (a
  244.      string or Lisp form).
  245.  
  246.  - Function: compiled-function-domain FUNCTION
  247.      This function returns the domain of compiled-function object
  248.      FUNCTION, if any.  The result will be a string or `nil'.  *Note
  249.      Domain Specification::.
  250.  
  251. 
  252. File: lispref.info,  Node: Disassembly,  Prev: Compiled-Function Objects,  Up: Byte Compilation
  253.  
  254. Disassembled Byte-Code
  255. ======================
  256.  
  257.    People do not write byte-code; that job is left to the byte compiler.
  258. But we provide a disassembler to satisfy a cat-like curiosity.  The
  259. disassembler converts the byte-compiled code into humanly readable form.
  260.  
  261.    The byte-code interpreter is implemented as a simple stack machine.
  262. It pushes values onto a stack of its own, then pops them off to use them
  263. in calculations whose results are themselves pushed back on the stack.
  264. When a byte-code function returns, it pops a value off the stack and
  265. returns it as the value of the function.
  266.  
  267.    In addition to the stack, byte-code functions can use, bind, and set
  268. ordinary Lisp variables, by transferring values between variables and
  269. the stack.
  270.  
  271.  - Command: disassemble OBJECT &optional STREAM
  272.      This function prints the disassembled code for OBJECT.  If STREAM
  273.      is supplied, then output goes there.  Otherwise, the disassembled
  274.      code is printed to the stream `standard-output'.  The argument
  275.      OBJECT can be a function name or a lambda expression.
  276.  
  277.      As a special exception, if this function is used interactively, it
  278.      outputs to a buffer named `*Disassemble*'.
  279.  
  280.    Here are two examples of using the `disassemble' function.  We have
  281. added explanatory comments to help you relate the byte-code to the Lisp
  282. source; these do not appear in the output of `disassemble'.  These
  283. examples show unoptimized byte-code.  Nowadays byte-code is usually
  284. optimized, but we did not want to rewrite these examples, since they
  285. still serve their purpose.
  286.  
  287.      (defun factorial (integer)
  288.        "Compute factorial of an integer."
  289.        (if (= 1 integer) 1
  290.          (* integer (factorial (1- integer)))))
  291.           => factorial
  292.      
  293.      (factorial 4)
  294.           => 24
  295.      
  296.      (disassemble 'factorial)
  297.           -| byte-code for factorial:
  298.       doc: Compute factorial of an integer.
  299.       args: (integer)
  300.      
  301.      0   constant 1              ; Push 1 onto stack.
  302.      
  303.      1   varref   integer        ; Get value of `integer'
  304.                                  ;   from the environment
  305.                                  ;   and push the value
  306.                                  ;   onto the stack.
  307.      
  308.      2   eqlsign                 ; Pop top two values off stack,
  309.                                  ;   compare them,
  310.                                  ;   and push result onto stack.
  311.      
  312.      3   goto-if-nil 10          ; Pop and test top of stack;
  313.                                  ;   if `nil', go to 10,
  314.                                  ;   else continue.
  315.      
  316.      6   constant 1              ; Push 1 onto top of stack.
  317.      
  318.      7   goto     17             ; Go to 17 (in this case, 1 will be
  319.                                  ;   returned by the function).
  320.      
  321.      10  constant *              ; Push symbol `*' onto stack.
  322.      
  323.      11  varref   integer        ; Push value of `integer' onto stack.
  324.      
  325.      12  constant factorial      ; Push `factorial' onto stack.
  326.      
  327.      13  varref   integer        ; Push value of `integer' onto stack.
  328.      
  329.      14  sub1                    ; Pop `integer', decrement value,
  330.                                  ;   push new value onto stack.
  331.      
  332.                                  ; Stack now contains:
  333.                                  ;   - decremented value of `integer'
  334.                                  ;   - `factorial'
  335.                                  ;   - value of `integer'
  336.                                  ;   - `*'
  337.      
  338.      15  call     1              ; Call function `factorial' using
  339.                                  ;   the first (i.e., the top) element
  340.                                  ;   of the stack as the argument;
  341.                                  ;   push returned value onto stack.
  342.      
  343.                                  ; Stack now contains:
  344.                                  ;   - result of recursive
  345.                                  ;        call to `factorial'
  346.                                  ;   - value of `integer'
  347.                                  ;   - `*'
  348.      
  349.      16  call     2              ; Using the first two
  350.                                  ;   (i.e., the top two)
  351.                                  ;   elements of the stack
  352.                                  ;   as arguments,
  353.                                  ;   call the function `*',
  354.                                  ;   pushing the result onto the stack.
  355.      
  356.      17  return                  ; Return the top element
  357.                                  ;   of the stack.
  358.           => nil
  359.  
  360.    The `silly-loop' function is somewhat more complex:
  361.  
  362.      (defun silly-loop (n)
  363.        "Return time before and after N iterations of a loop."
  364.        (let ((t1 (current-time-string)))
  365.          (while (> (setq n (1- n))
  366.                    0))
  367.          (list t1 (current-time-string))))
  368.           => silly-loop
  369.      
  370.      (disassemble 'silly-loop)
  371.           -| byte-code for silly-loop:
  372.       doc: Return time before and after N iterations of a loop.
  373.       args: (n)
  374.      
  375.      0   constant current-time-string  ; Push
  376.                                        ;   `current-time-string'
  377.                                        ;   onto top of stack.
  378.      
  379.      1   call     0              ; Call `current-time-string'
  380.                                  ;    with no argument,
  381.                                  ;    pushing result onto stack.
  382.      
  383.      2   varbind  t1             ; Pop stack and bind `t1'
  384.                                  ;   to popped value.
  385.      
  386.      3   varref   n              ; Get value of `n' from
  387.                                  ;   the environment and push
  388.                                  ;   the value onto the stack.
  389.      
  390.      4   sub1                    ; Subtract 1 from top of stack.
  391.      
  392.      5   dup                     ; Duplicate the top of the stack;
  393.                                  ;   i.e., copy the top of
  394.                                  ;   the stack and push the
  395.                                  ;   copy onto the stack.
  396.      
  397.      6   varset   n              ; Pop the top of the stack,
  398.                                  ;   and bind `n' to the value.
  399.      
  400.                                  ; In effect, the sequence `dup varset'
  401.                                  ;   copies the top of the stack
  402.                                  ;   into the value of `n'
  403.                                  ;   without popping it.
  404.      
  405.      7   constant 0              ; Push 0 onto stack.
  406.      
  407.      8   gtr                     ; Pop top two values off stack,
  408.                                  ;   test if N is greater than 0
  409.                                  ;   and push result onto stack.
  410.      
  411.      9   goto-if-nil-else-pop 17 ; Goto 17 if `n' <= 0
  412.                                  ;   (this exits the while loop).
  413.                                  ;   else pop top of stack
  414.                                  ;   and continue
  415.      
  416.      12  constant nil            ; Push `nil' onto stack
  417.                                  ;   (this is the body of the loop).
  418.      
  419.      13  discard                 ; Discard result of the body
  420.                                  ;   of the loop (a while loop
  421.                                  ;   is always evaluated for
  422.                                  ;   its side effects).
  423.      
  424.      14  goto     3              ; Jump back to beginning
  425.                                  ;   of while loop.
  426.      
  427.      17  discard                 ; Discard result of while loop
  428.                                  ;   by popping top of stack.
  429.                                  ;   This result is the value `nil' that
  430.                                  ;   was not popped by the goto at 9.
  431.      
  432.      18  varref   t1             ; Push value of `t1' onto stack.
  433.      
  434.      19  constant current-time-string  ; Push
  435.                                        ;   `current-time-string'
  436.                                        ;   onto top of stack.
  437.      
  438.      20  call     0              ; Call `current-time-string' again.
  439.      
  440.      21  list2                   ; Pop top two elements off stack,
  441.                                  ;   create a list of them,
  442.                                  ;   and push list onto stack.
  443.      
  444.      22  unbind   1              ; Unbind `t1' in local environment.
  445.      
  446.      23  return                  ; Return value of the top of stack.
  447.      
  448.           => nil
  449.  
  450. 
  451. File: lispref.info,  Node: Debugging,  Next: Read and Print,  Prev: Byte Compilation,  Up: Top
  452.  
  453. Debugging Lisp Programs
  454. ***********************
  455.  
  456.    There are three ways to investigate a problem in an XEmacs Lisp
  457. program, depending on what you are doing with the program when the
  458. problem appears.
  459.  
  460.    * If the problem occurs when you run the program, you can use a Lisp
  461.      debugger (either the default debugger or Edebug) to investigate
  462.      what is happening during execution.
  463.  
  464.    * If the problem is syntactic, so that Lisp cannot even read the
  465.      program, you can use the XEmacs facilities for editing Lisp to
  466.      localize it.
  467.  
  468.    * If the problem occurs when trying to compile the program with the
  469.      byte compiler, you need to know how to examine the compiler's
  470.      input buffer.
  471.  
  472. * Menu:
  473.  
  474. * Debugger::            How the XEmacs Lisp debugger is implemented.
  475. * Syntax Errors::       How to find syntax errors.
  476. * Compilation Errors::  How to find errors that show up in byte compilation.
  477. * Edebug::        A source-level XEmacs Lisp debugger.
  478.  
  479.    Another useful debugging tool is the dribble file.  When a dribble
  480. file is open, XEmacs copies all keyboard input characters to that file.
  481. Afterward, you can examine the file to find out what input was used.
  482. *Note Terminal Input::.
  483.  
  484.    For debugging problems in terminal descriptions, the
  485. `open-termscript' function can be useful.  *Note Terminal Output::.
  486.  
  487. 
  488. File: lispref.info,  Node: Debugger,  Next: Syntax Errors,  Up: Debugging
  489.  
  490. The Lisp Debugger
  491. =================
  492.  
  493.    The "Lisp debugger" provides the ability to suspend evaluation of a
  494. form.  While evaluation is suspended (a state that is commonly known as
  495. a "break"), you may examine the run time stack, examine the values of
  496. local or global variables, or change those values.  Since a break is a
  497. recursive edit, all the usual editing facilities of XEmacs are
  498. available; you can even run programs that will enter the debugger
  499. recursively.  *Note Recursive Editing::.
  500.  
  501. * Menu:
  502.  
  503. * Error Debugging::       Entering the debugger when an error happens.
  504. * Infinite Loops::      Stopping and debugging a program that doesn't exit.
  505. * Function Debugging::    Entering it when a certain function is called.
  506. * Explicit Debug::        Entering it at a certain point in the program.
  507. * Using Debugger::        What the debugger does; what you see while in it.
  508. * Debugger Commands::     Commands used while in the debugger.
  509. * Invoking the Debugger:: How to call the function `debug'.
  510. * Internals of Debugger:: Subroutines of the debugger, and global variables.
  511.  
  512. 
  513. File: lispref.info,  Node: Error Debugging,  Next: Infinite Loops,  Up: Debugger
  514.  
  515. Entering the Debugger on an Error
  516. ---------------------------------
  517.  
  518.    The most important time to enter the debugger is when a Lisp error
  519. happens.  This allows you to investigate the immediate causes of the
  520. error.
  521.  
  522.    However, entry to the debugger is not a normal consequence of an
  523. error.  Many commands frequently get Lisp errors when invoked in
  524. inappropriate contexts (such as `C-f' at the end of the buffer) and
  525. during ordinary editing it would be very unpleasant to enter the
  526. debugger each time this happens.  If you want errors to enter the
  527. debugger, set the variable `debug-on-error' to non-`nil'.
  528.  
  529.  - User Option: debug-on-error
  530.      This variable determines whether the debugger is called when an
  531.      error is signaled and not handled.  If `debug-on-error' is `t', all
  532.      errors call the debugger.  If it is `nil', none call the debugger.
  533.  
  534.      The value can also be a list of error conditions that should call
  535.      the debugger.  For example, if you set it to the list
  536.      `(void-variable)', then only errors about a variable that has no
  537.      value invoke the debugger.
  538.  
  539.      When this variable is non-`nil', Emacs does not catch errors that
  540.      happen in process filter functions and sentinels.  Therefore, these
  541.      errors also can invoke the debugger.  *Note Processes::.
  542.  
  543.  - User Option: debug-ignored-errors
  544.      This variable specifies certain kinds of errors that should not
  545.      enter the debugger.  Its value is a list of error condition
  546.      symbols and/or regular expressions.  If the error has any of those
  547.      condition symbols, or if the error message matches any of the
  548.      regular expressions, then that error does not enter the debugger,
  549.      regardless of the value of `debug-on-error'.
  550.  
  551.      The normal value of this variable lists several errors that happen
  552.      often during editing but rarely result from bugs in Lisp programs.
  553.  
  554.    To debug an error that happens during loading of the `.emacs' file,
  555. use the option `-debug-init', which binds `debug-on-error' to `t' while
  556. `.emacs' is loaded and inhibits use of `condition-case' to catch init
  557. file errors.
  558.  
  559.    If your `.emacs' file sets `debug-on-error', the effect may not last
  560. past the end of loading `.emacs'.  (This is an undesirable byproduct of
  561. the code that implements the `-debug-init' command line option.)  The
  562. best way to make `.emacs' set `debug-on-error' permanently is with
  563. `after-init-hook', like this:
  564.  
  565.      (add-hook 'after-init-hook
  566.                '(lambda () (setq debug-on-error t)))
  567.  
  568.  - User Option: debug-on-signal
  569.      This variable is similar to `debug-on-error' but breaks whenever
  570.      an error is signalled, regardless of whether it would be handled.
  571.  
  572. 
  573. File: lispref.info,  Node: Infinite Loops,  Next: Function Debugging,  Prev: Error Debugging,  Up: Debugger
  574.  
  575. Debugging Infinite Loops
  576. ------------------------
  577.  
  578.    When a program loops infinitely and fails to return, your first
  579. problem is to stop the loop.  On most operating systems, you can do this
  580. with `C-g', which causes quit.
  581.  
  582.    Ordinary quitting gives no information about why the program was
  583. looping.  To get more information, you can set the variable
  584. `debug-on-quit' to non-`nil'.  Quitting with `C-g' is not considered an
  585. error, and `debug-on-error' has no effect on the handling of `C-g'.
  586. Likewise, `debug-on-quit' has no effect on errors.
  587.  
  588.    Once you have the debugger running in the middle of the infinite
  589. loop, you can proceed from the debugger using the stepping commands.
  590. If you step through the entire loop, you will probably get enough
  591. information to solve the problem.
  592.  
  593.  - User Option: debug-on-quit
  594.      This variable determines whether the debugger is called when `quit'
  595.      is signaled and not handled.  If `debug-on-quit' is non-`nil',
  596.      then the debugger is called whenever you quit (that is, type
  597.      `C-g').  If `debug-on-quit' is `nil', then the debugger is not
  598.      called when you quit.  *Note Quitting::.
  599.  
  600. 
  601. File: lispref.info,  Node: Function Debugging,  Next: Explicit Debug,  Prev: Infinite Loops,  Up: Debugger
  602.  
  603. Entering the Debugger on a Function Call
  604. ----------------------------------------
  605.  
  606.    To investigate a problem that happens in the middle of a program, one
  607. useful technique is to enter the debugger whenever a certain function is
  608. called.  You can do this to the function in which the problem occurs,
  609. and then step through the function, or you can do this to a function
  610. called shortly before the problem, step quickly over the call to that
  611. function, and then step through its caller.
  612.  
  613.  - Command: debug-on-entry FUNCTION-NAME
  614.      This function requests FUNCTION-NAME to invoke the debugger each
  615.      time it is called.  It works by inserting the form `(debug
  616.      'debug)' into the function definition as the first form.
  617.  
  618.      Any function defined as Lisp code may be set to break on entry,
  619.      regardless of whether it is interpreted code or compiled code.  If
  620.      the function is a command, it will enter the debugger when called
  621.      from Lisp and when called interactively (after the reading of the
  622.      arguments).  You can't debug primitive functions (i.e., those
  623.      written in C) this way.
  624.  
  625.      When `debug-on-entry' is called interactively, it prompts for
  626.      FUNCTION-NAME in the minibuffer.
  627.  
  628.      If the function is already set up to invoke the debugger on entry,
  629.      `debug-on-entry' does nothing.
  630.  
  631.      *Note:* if you redefine a function after using `debug-on-entry' on
  632.      it, the code to enter the debugger is lost.
  633.  
  634.      `debug-on-entry' returns FUNCTION-NAME.
  635.  
  636.           (defun fact (n)
  637.             (if (zerop n) 1
  638.                 (* n (fact (1- n)))))
  639.                => fact
  640.           (debug-on-entry 'fact)
  641.                => fact
  642.           (fact 3)
  643.           
  644.           ------ Buffer: *Backtrace* ------
  645.           Entering:
  646.           * fact(3)
  647.             eval-region(4870 4878 t)
  648.             byte-code("...")
  649.             eval-last-sexp(nil)
  650.             (let ...)
  651.             eval-insert-last-sexp(nil)
  652.           * call-interactively(eval-insert-last-sexp)
  653.           ------ Buffer: *Backtrace* ------
  654.           
  655.           (symbol-function 'fact)
  656.                => (lambda (n)
  657.                     (debug (quote debug))
  658.                     (if (zerop n) 1 (* n (fact (1- n)))))
  659.  
  660.  - Command: cancel-debug-on-entry FUNCTION-NAME
  661.      This function undoes the effect of `debug-on-entry' on
  662.      FUNCTION-NAME.  When called interactively, it prompts for
  663.      FUNCTION-NAME in the minibuffer.  If FUNCTION-NAME is `nil' or the
  664.      empty string, it cancels debugging for all functions.
  665.  
  666.      If `cancel-debug-on-entry' is called more than once on the same
  667.      function, the second call does nothing.  `cancel-debug-on-entry'
  668.      returns FUNCTION-NAME.
  669.  
  670. 
  671. File: lispref.info,  Node: Explicit Debug,  Next: Using Debugger,  Prev: Function Debugging,  Up: Debugger
  672.  
  673. Explicit Entry to the Debugger
  674. ------------------------------
  675.  
  676.    You can cause the debugger to be called at a certain point in your
  677. program by writing the expression `(debug)' at that point.  To do this,
  678. visit the source file, insert the text `(debug)' at the proper place,
  679. and type `C-M-x'.  Be sure to undo this insertion before you save the
  680. file!
  681.  
  682.    The place where you insert `(debug)' must be a place where an
  683. additional form can be evaluated and its value ignored.  (If the value
  684. of `(debug)' isn't ignored, it will alter the execution of the
  685. program!)  The most common suitable places are inside a `progn' or an
  686. implicit `progn' (*note Sequencing::.).
  687.  
  688. 
  689. File: lispref.info,  Node: Using Debugger,  Next: Debugger Commands,  Prev: Explicit Debug,  Up: Debugger
  690.  
  691. Using the Debugger
  692. ------------------
  693.  
  694.    When the debugger is entered, it displays the previously selected
  695. buffer in one window and a buffer named `*Backtrace*' in another
  696. window.  The backtrace buffer contains one line for each level of Lisp
  697. function execution currently going on.  At the beginning of this buffer
  698. is a message describing the reason that the debugger was invoked (such
  699. as the error message and associated data, if it was invoked due to an
  700. error).
  701.  
  702.    The backtrace buffer is read-only and uses a special major mode,
  703. Debugger mode, in which letters are defined as debugger commands.  The
  704. usual XEmacs editing commands are available; thus, you can switch
  705. windows to examine the buffer that was being edited at the time of the
  706. error, switch buffers, visit files, or do any other sort of editing.
  707. However, the debugger is a recursive editing level (*note Recursive
  708. Editing::.)  and it is wise to go back to the backtrace buffer and exit
  709. the debugger (with the `q' command) when you are finished with it.
  710. Exiting the debugger gets out of the recursive edit and kills the
  711. backtrace buffer.
  712.  
  713.    The backtrace buffer shows you the functions that are executing and
  714. their argument values.  It also allows you to specify a stack frame by
  715. moving point to the line describing that frame.  (A stack frame is the
  716. place where the Lisp interpreter records information about a particular
  717. invocation of a function.)  The frame whose line point is on is
  718. considered the "current frame".  Some of the debugger commands operate
  719. on the current frame.
  720.  
  721.    The debugger itself must be run byte-compiled, since it makes
  722. assumptions about how many stack frames are used for the debugger
  723. itself.  These assumptions are false if the debugger is running
  724. interpreted.
  725.  
  726. 
  727. File: lispref.info,  Node: Debugger Commands,  Next: Invoking the Debugger,  Prev: Using Debugger,  Up: Debugger
  728.  
  729. Debugger Commands
  730. -----------------
  731.  
  732.    Inside the debugger (in Debugger mode), these special commands are
  733. available in addition to the usual cursor motion commands.  (Keep in
  734. mind that all the usual facilities of XEmacs, such as switching windows
  735. or buffers, are still available.)
  736.  
  737.    The most important use of debugger commands is for stepping through
  738. code, so that you can see how control flows.  The debugger can step
  739. through the control structures of an interpreted function, but cannot do
  740. so in a byte-compiled function.  If you would like to step through a
  741. byte-compiled function, replace it with an interpreted definition of the
  742. same function.  (To do this, visit the source file for the function and
  743. type `C-M-x' on its definition.)
  744.  
  745.    Here is a list of Debugger mode commands:
  746.  
  747. `c'
  748.      Exit the debugger and continue execution.  This resumes execution
  749.      of the program as if the debugger had never been entered (aside
  750.      from the effect of any variables or data structures you may have
  751.      changed while inside the debugger).
  752.  
  753.      Continuing when an error or quit was signalled will cause the
  754.      normal action of the signalling to take place.  If you do not want
  755.      this to happen, but instead want the program execution to continue
  756.      as if the call to `signal' did not occur, use the `r' command.
  757.  
  758. `d'
  759.      Continue execution, but enter the debugger the next time any Lisp
  760.      function is called.  This allows you to step through the
  761.      subexpressions of an expression, seeing what values the
  762.      subexpressions compute, and what else they do.
  763.  
  764.      The stack frame made for the function call which enters the
  765.      debugger in this way will be flagged automatically so that the
  766.      debugger will be called again when the frame is exited.  You can
  767.      use the `u' command to cancel this flag.
  768.  
  769. `b'
  770.      Flag the current frame so that the debugger will be entered when
  771.      the frame is exited.  Frames flagged in this way are marked with
  772.      stars in the backtrace buffer.
  773.  
  774. `u'
  775.      Don't enter the debugger when the current frame is exited.  This
  776.      cancels a `b' command on that frame.
  777.  
  778. `e'
  779.      Read a Lisp expression in the minibuffer, evaluate it, and print
  780.      the value in the echo area.  The debugger alters certain important
  781.      variables, and the current buffer, as part of its operation; `e'
  782.      temporarily restores their outside-the-debugger values so you can
  783.      examine them.  This makes the debugger more transparent.  By
  784.      contrast, `M-:' does nothing special in the debugger; it shows you
  785.      the variable values within the debugger.
  786.  
  787. `q'
  788.      Terminate the program being debugged; return to top-level XEmacs
  789.      command execution.
  790.  
  791.      If the debugger was entered due to a `C-g' but you really want to
  792.      quit, and not debug, use the `q' command.
  793.  
  794. `r'
  795.      Return a value from the debugger.  The value is computed by
  796.      reading an expression with the minibuffer and evaluating it.
  797.  
  798.      The `r' command is useful when the debugger was invoked due to exit
  799.      from a Lisp call frame (as requested with `b'); then the value
  800.      specified in the `r' command is used as the value of that frame.
  801.      It is also useful if you call `debug' and use its return value.
  802.  
  803.      If the debugger was entered at the beginning of a function call,
  804.      `r' has the same effect as `c', and the specified return value
  805.      does not matter.
  806.  
  807.      If the debugger was entered through a call to `signal' (i.e. as a
  808.      result of an error or quit), then returning a value will cause the
  809.      call to `signal' itself to return, rather than throwing to
  810.      top-level or invoking a handler, as is normal.  This allows you to
  811.      correct an error (e.g. the type of an argument was wrong) or
  812.      continue from a `debug-on-quit' as if it never happened.
  813.  
  814.      Note that some errors (e.g. any error signalled using the `error'
  815.      function, and many errors signalled from a primitive function) are
  816.      not continuable.  If you return a value from them and continue
  817.      execution, then the error will immediately be signalled again.
  818.      Other errors (e.g. wrong-type-argument errors) will be continually
  819.      resignalled until the problem is corrected.
  820.  
  821. 
  822. File: lispref.info,  Node: Invoking the Debugger,  Next: Internals of Debugger,  Prev: Debugger Commands,  Up: Debugger
  823.  
  824. Invoking the Debugger
  825. ---------------------
  826.  
  827.    Here we describe fully the function used to invoke the debugger.
  828.  
  829.  - Function: debug &rest DEBUGGER-ARGS
  830.      This function enters the debugger.  It switches buffers to a buffer
  831.      named `*Backtrace*' (or `*Backtrace*<2>' if it is the second
  832.      recursive entry to the debugger, etc.), and fills it with
  833.      information about the stack of Lisp function calls.  It then
  834.      enters a recursive edit, showing the backtrace buffer in Debugger
  835.      mode.
  836.  
  837.      The Debugger mode `c' and `r' commands exit the recursive edit;
  838.      then `debug' switches back to the previous buffer and returns to
  839.      whatever called `debug'.  This is the only way the function
  840.      `debug' can return to its caller.
  841.  
  842.      If the first of the DEBUGGER-ARGS passed to `debug' is `nil' (or
  843.      if it is not one of the special values in the table below), then
  844.      `debug' displays the rest of its arguments at the top of the
  845.      `*Backtrace*' buffer.  This mechanism is used to display a message
  846.      to the user.
  847.  
  848.      However, if the first argument passed to `debug' is one of the
  849.      following special values, then it has special significance.
  850.      Normally, these values are passed to `debug' only by the internals
  851.      of XEmacs and the debugger, and not by programmers calling `debug'.
  852.  
  853.      The special values are:
  854.  
  855.     `lambda'
  856.           A first argument of `lambda' means `debug' was called because
  857.           of entry to a function when `debug-on-next-call' was
  858.           non-`nil'.  The debugger displays `Entering:' as a line of
  859.           text at the top of the buffer.
  860.  
  861.     `debug'
  862.           `debug' as first argument indicates a call to `debug' because
  863.           of entry to a function that was set to debug on entry.  The
  864.           debugger displays `Entering:', just as in the `lambda' case.
  865.           It also marks the stack frame for that function so that it
  866.           will invoke the debugger when exited.
  867.  
  868.     `t'
  869.           When the first argument is `t', this indicates a call to
  870.           `debug' due to evaluation of a list form when
  871.           `debug-on-next-call' is non-`nil'.  The debugger displays the
  872.           following as the top line in the buffer:
  873.  
  874.                Beginning evaluation of function call form:
  875.  
  876.     `exit'
  877.           When the first argument is `exit', it indicates the exit of a
  878.           stack frame previously marked to invoke the debugger on exit.
  879.           The second argument given to `debug' in this case is the
  880.           value being returned from the frame.  The debugger displays
  881.           `Return value:' on the top line of the buffer, followed by
  882.           the value being returned.
  883.  
  884.     `error'
  885.           When the first argument is `error', the debugger indicates
  886.           that it is being entered because an error or `quit' was
  887.           signaled and not handled, by displaying `Signaling:' followed
  888.           by the error signaled and any arguments to `signal'.  For
  889.           example,
  890.  
  891.                (let ((debug-on-error t))
  892.                  (/ 1 0))
  893.                
  894.                ------ Buffer: *Backtrace* ------
  895.                Signaling: (arith-error)
  896.                  /(1 0)
  897.                ...
  898.                ------ Buffer: *Backtrace* ------
  899.  
  900.           If an error was signaled, presumably the variable
  901.           `debug-on-error' is non-`nil'.  If `quit' was signaled, then
  902.           presumably the variable `debug-on-quit' is non-`nil'.
  903.  
  904.     `nil'
  905.           Use `nil' as the first of the DEBUGGER-ARGS when you want to
  906.           enter the debugger explicitly.  The rest of the DEBUGGER-ARGS
  907.           are printed on the top line of the buffer.  You can use this
  908.           feature to display messages--for example, to remind yourself
  909.           of the conditions under which `debug' is called.
  910.  
  911. 
  912. File: lispref.info,  Node: Internals of Debugger,  Prev: Invoking the Debugger,  Up: Debugger
  913.  
  914. Internals of the Debugger
  915. -------------------------
  916.  
  917.    This section describes functions and variables used internally by the
  918. debugger.
  919.  
  920.  - Variable: debugger
  921.      The value of this variable is the function to call to invoke the
  922.      debugger.  Its value must be a function of any number of arguments
  923.      (or, more typically, the name of a function).  Presumably this
  924.      function will enter some kind of debugger.  The default value of
  925.      the variable is `debug'.
  926.  
  927.      The first argument that Lisp hands to the function indicates why it
  928.      was called.  The convention for arguments is detailed in the
  929.      description of `debug'.
  930.  
  931.  - Command: backtrace &optional STREAM DETAILED
  932.      This function prints a trace of Lisp function calls currently
  933.      active.  This is the function used by `debug' to fill up the
  934.      `*Backtrace*' buffer.  It is written in C, since it must have
  935.      access to the stack to determine which function calls are active.
  936.      The return value is always `nil'.
  937.  
  938.      The backtrace is normally printed to `standard-output', but this
  939.      can be changed by specifying a value for STREAM.  If DETAILED is
  940.      non-`nil', the backtrace also shows places where currently active
  941.      variable bindings, catches, condition-cases, and unwind-protects
  942.      were made as well as function calls.
  943.  
  944.      In the following example, a Lisp expression calls `backtrace'
  945.      explicitly.  This prints the backtrace to the stream
  946.      `standard-output': in this case, to the buffer `backtrace-output'.
  947.      Each line of the backtrace represents one function call.  The
  948.      line shows the values of the function's arguments if they are all
  949.      known.  If they are still being computed, the line says so.  The
  950.      arguments of special forms are elided.
  951.  
  952.           (with-output-to-temp-buffer "backtrace-output"
  953.             (let ((var 1))
  954.               (save-excursion
  955.                 (setq var (eval '(progn
  956.                                    (1+ var)
  957.                                    (list 'testing (backtrace))))))))
  958.           
  959.                => nil
  960.  
  961.           ----------- Buffer: backtrace-output ------------
  962.             backtrace()
  963.             (list ...computing arguments...)
  964.             (progn ...)
  965.             eval((progn (1+ var) (list (quote testing) (backtrace))))
  966.             (setq ...)
  967.             (save-excursion ...)
  968.             (let ...)
  969.             (with-output-to-temp-buffer ...)
  970.             eval-region(1973 2142 #<buffer *scratch*>)
  971.             byte-code("...  for eval-print-last-sexp ...")
  972.             eval-print-last-sexp(nil)
  973.           * call-interactively(eval-print-last-sexp)
  974.           ----------- Buffer: backtrace-output ------------
  975.  
  976.      The character `*' indicates a frame whose debug-on-exit flag is
  977.      set.
  978.  
  979.  - Variable: debug-on-next-call
  980.      If this variable is non-`nil', it says to call the debugger before
  981.      the next `eval', `apply' or `funcall'.  Entering the debugger sets
  982.      `debug-on-next-call' to `nil'.
  983.  
  984.      The `d' command in the debugger works by setting this variable.
  985.  
  986.  - Function: backtrace-debug LEVEL FLAG
  987.      This function sets the debug-on-exit flag of the stack frame LEVEL
  988.      levels down the stack, giving it the value FLAG.  If FLAG is
  989.      non-`nil', this will cause the debugger to be entered when that
  990.      frame later exits.  Even a nonlocal exit through that frame will
  991.      enter the debugger.
  992.  
  993.      This function is used only by the debugger.
  994.  
  995.  - Variable: command-debug-status
  996.      This variable records the debugging status of the current
  997.      interactive command.  Each time a command is called interactively,
  998.      this variable is bound to `nil'.  The debugger can set this
  999.      variable to leave information for future debugger invocations
  1000.      during the same command.
  1001.  
  1002.      The advantage, for the debugger, of using this variable rather than
  1003.      another global variable is that the data will never carry over to a
  1004.      subsequent command invocation.
  1005.  
  1006.  - Function: backtrace-frame FRAME-NUMBER
  1007.      The function `backtrace-frame' is intended for use in Lisp
  1008.      debuggers.  It returns information about what computation is
  1009.      happening in the stack frame FRAME-NUMBER levels down.
  1010.  
  1011.      If that frame has not evaluated the arguments yet (or is a special
  1012.      form), the value is `(nil FUNCTION ARG-FORMS...)'.
  1013.  
  1014.      If that frame has evaluated its arguments and called its function
  1015.      already, the value is `(t FUNCTION ARG-VALUES...)'.
  1016.  
  1017.      In the return value, FUNCTION is whatever was supplied as the CAR
  1018.      of the evaluated list, or a `lambda' expression in the case of a
  1019.      macro call.  If the function has a `&rest' argument, that is
  1020.      represented as the tail of the list ARG-VALUES.
  1021.  
  1022.      If FRAME-NUMBER is out of range, `backtrace-frame' returns `nil'.
  1023.  
  1024. 
  1025. File: lispref.info,  Node: Syntax Errors,  Next: Compilation Errors,  Prev: Debugger,  Up: Debugging
  1026.  
  1027. Debugging Invalid Lisp Syntax
  1028. =============================
  1029.  
  1030.    The Lisp reader reports invalid syntax, but cannot say where the real
  1031. problem is.  For example, the error "End of file during parsing" in
  1032. evaluating an expression indicates an excess of open parentheses (or
  1033. square brackets).  The reader detects this imbalance at the end of the
  1034. file, but it cannot figure out where the close parenthesis should have
  1035. been.  Likewise, "Invalid read syntax: ")"" indicates an excess close
  1036. parenthesis or missing open parenthesis, but does not say where the
  1037. missing parenthesis belongs.  How, then, to find what to change?
  1038.  
  1039.    If the problem is not simply an imbalance of parentheses, a useful
  1040. technique is to try `C-M-e' at the beginning of each defun, and see if
  1041. it goes to the place where that defun appears to end.  If it does not,
  1042. there is a problem in that defun.
  1043.  
  1044.    However, unmatched parentheses are the most common syntax errors in
  1045. Lisp, and we can give further advice for those cases.
  1046.  
  1047. * Menu:
  1048.  
  1049. * Excess Open::     How to find a spurious open paren or missing close.
  1050. * Excess Close::    How to find a spurious close paren or missing open.
  1051.  
  1052. 
  1053. File: lispref.info,  Node: Excess Open,  Next: Excess Close,  Up: Syntax Errors
  1054.  
  1055. Excess Open Parentheses
  1056. -----------------------
  1057.  
  1058.    The first step is to find the defun that is unbalanced.  If there is
  1059. an excess open parenthesis, the way to do this is to insert a close
  1060. parenthesis at the end of the file and type `C-M-b' (`backward-sexp').
  1061. This will move you to the beginning of the defun that is unbalanced.
  1062. (Then type `C-<SPC> C-_ C-u C-<SPC>' to set the mark there, undo the
  1063. insertion of the close parenthesis, and finally return to the mark.)
  1064.  
  1065.    The next step is to determine precisely what is wrong.  There is no
  1066. way to be sure of this except to study the program, but often the
  1067. existing indentation is a clue to where the parentheses should have
  1068. been.  The easiest way to use this clue is to reindent with `C-M-q' and
  1069. see what moves.
  1070.  
  1071.    Before you do this, make sure the defun has enough close parentheses.
  1072. Otherwise, `C-M-q' will get an error, or will reindent all the rest of
  1073. the file until the end.  So move to the end of the defun and insert a
  1074. close parenthesis there.  Don't use `C-M-e' to move there, since that
  1075. too will fail to work until the defun is balanced.
  1076.  
  1077.    Now you can go to the beginning of the defun and type `C-M-q'.
  1078. Usually all the lines from a certain point to the end of the function
  1079. will shift to the right.  There is probably a missing close parenthesis,
  1080. or a superfluous open parenthesis, near that point.  (However, don't
  1081. assume this is true; study the code to make sure.)  Once you have found
  1082. the discrepancy, undo the `C-M-q' with `C-_', since the old indentation
  1083. is probably appropriate to the intended parentheses.
  1084.  
  1085.    After you think you have fixed the problem, use `C-M-q' again.  If
  1086. the old indentation actually fit the intended nesting of parentheses,
  1087. and you have put back those parentheses, `C-M-q' should not change
  1088. anything.
  1089.  
  1090. 
  1091. File: lispref.info,  Node: Excess Close,  Prev: Excess Open,  Up: Syntax Errors
  1092.  
  1093. Excess Close Parentheses
  1094. ------------------------
  1095.  
  1096.    To deal with an excess close parenthesis, first insert an open
  1097. parenthesis at the beginning of the file, back up over it, and type
  1098. `C-M-f' to find the end of the unbalanced defun.  (Then type `C-<SPC>
  1099. C-_ C-u C-<SPC>' to set the mark there, undo the insertion of the open
  1100. parenthesis, and finally return to the mark.)
  1101.  
  1102.    Then find the actual matching close parenthesis by typing `C-M-f' at
  1103. the beginning of the defun.  This will leave you somewhere short of the
  1104. place where the defun ought to end.  It is possible that you will find
  1105. a spurious close parenthesis in that vicinity.
  1106.  
  1107.    If you don't see a problem at that point, the next thing to do is to
  1108. type `C-M-q' at the beginning of the defun.  A range of lines will
  1109. probably shift left; if so, the missing open parenthesis or spurious
  1110. close parenthesis is probably near the first of those lines.  (However,
  1111. don't assume this is true; study the code to make sure.)  Once you have
  1112. found the discrepancy, undo the `C-M-q' with `C-_', since the old
  1113. indentation is probably appropriate to the intended parentheses.
  1114.  
  1115.    After you think you have fixed the problem, use `C-M-q' again.  If
  1116. the old indentation actually fit the intended nesting of parentheses,
  1117. and you have put back those parentheses, `C-M-q' should not change
  1118. anything.
  1119.  
  1120. 
  1121. File: lispref.info,  Node: Compilation Errors,  Next: Edebug,  Prev: Syntax Errors,  Up: Debugging
  1122.  
  1123. Debugging Problems in Compilation
  1124. =================================
  1125.  
  1126.    When an error happens during byte compilation, it is normally due to
  1127. invalid syntax in the program you are compiling.  The compiler prints a
  1128. suitable error message in the `*Compile-Log*' buffer, and then stops.
  1129. The message may state a function name in which the error was found, or
  1130. it may not.  Either way, here is how to find out where in the file the
  1131. error occurred.
  1132.  
  1133.    What you should do is switch to the buffer ` *Compiler Input*'.
  1134. (Note that the buffer name starts with a space, so it does not show up
  1135. in `M-x list-buffers'.)  This buffer contains the program being
  1136. compiled, and point shows how far the byte compiler was able to read.
  1137.  
  1138.    If the error was due to invalid Lisp syntax, point shows exactly
  1139. where the invalid syntax was *detected*.  The cause of the error is not
  1140. necessarily near by!  Use the techniques in the previous section to find
  1141. the error.
  1142.  
  1143.    If the error was detected while compiling a form that had been read
  1144. successfully, then point is located at the end of the form.  In this
  1145. case, this technique can't localize the error precisely, but can still
  1146. show you which function to check.
  1147.  
  1148. 
  1149. File: lispref.info,  Node: Edebug,  Prev: Compilation Errors,  Up: Debugging
  1150.  
  1151. Edebug
  1152. ======
  1153.  
  1154.    Edebug is a source-level debugger for XEmacs Lisp programs that
  1155. provides the following features:
  1156.  
  1157.    * Step through evaluation, stopping before and after each expression.
  1158.  
  1159.    * Set conditional or unconditional breakpoints, install embedded
  1160.      breakpoints, or a global break event.
  1161.  
  1162.    * Trace slow or fast stopping briefly at each stop point, or each
  1163.      breakpoint.
  1164.  
  1165.    * Display expression results and evaluate expressions as if outside
  1166.      of Edebug.  Interface with the custom printing package for
  1167.      printing circular structures.
  1168.  
  1169.    * Automatically reevaluate a list of expressions and display their
  1170.      results each time Edebug updates the display.
  1171.  
  1172.    * Output trace info on function enter and exit.
  1173.  
  1174.    * Errors stop before the source causing the error.
  1175.  
  1176.    * Display backtrace without Edebug calls.
  1177.  
  1178.    * Allow specification of argument evaluation for macros and defining
  1179.      forms.
  1180.  
  1181.    * Provide rudimentary coverage testing and display of frequency
  1182.      counts.
  1183.  
  1184.    The first three sections should tell you enough about Edebug to
  1185. enable you to use it.
  1186.  
  1187. * Menu:
  1188.  
  1189. * Using Edebug::        Introduction to use of Edebug.
  1190. * Instrumenting::        You must first instrument code.
  1191. * Edebug Execution Modes::    Execution modes, stopping more or less often.
  1192. * Jumping::            Commands to jump to a specified place.
  1193. * Edebug Misc::            Miscellaneous commands.
  1194. * Breakpoints::            Setting breakpoints to make the program stop.
  1195. * Trapping Errors::        trapping errors with Edebug.
  1196. * Edebug Views::        Views inside and outside of Edebug.
  1197. * Edebug Eval::            Evaluating expressions within Edebug.
  1198. * Eval List::            Automatic expression evaluation.
  1199. * Reading in Edebug::        Customization of reading.
  1200. * Printing in Edebug::        Customization of printing.
  1201. * Tracing::            How to produce tracing output.
  1202. * Coverage Testing::        How to test evaluation coverage.
  1203. * The Outside Context::        Data that Edebug saves and restores.
  1204. * Instrumenting Macro Calls::    Specifying how to handle macro calls.
  1205. * Edebug Options::        Option variables for customizing Edebug.
  1206.  
  1207.